﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace mirror
{
    public class cSimpleBloomEffect : cBaseRenderEffect
    {
        Effect bloomEffect;

        public cSimpleBloomEffect(mirror.Game1 zGame)
            : base(zGame.GraphicsDevice, zGame.spriteBatch)
        {

        }

        public override void Initialise(mirror.Game1 zGame)
        {
            bloomEffect = zGame.Content.Load<Effect>("SimpleBloom");
        }

        public override void Draw(GameTime gameTime,
                         RenderTarget2D resolveTarget,
                         RenderTarget2D renderTarget1,
                         RenderTarget2D renderTarget2)
        {
            mGraphicsDevice.SetRenderTarget(resolveTarget);
            
            Viewport viewport = mGraphicsDevice.Viewport;

            mSpriteBatch.Begin( SpriteSortMode.Immediate, BlendState.Opaque);

             bloomEffect.CurrentTechnique.Passes[0].Apply();
        
            // Draw the quad.
             mSpriteBatch.Draw(resolveTarget, new Rectangle(0, 0, viewport.Width, viewport.Height), Color.White);
            mSpriteBatch.End();

            mGraphicsDevice.SetRenderTarget(null);
        }
    }
}
